<template>
	<view class="mian">
	
	  <!-- #ifdef MP-WEIXIN -->
	  	<navbar :bgColor="bgColor" :btnColors='btnColor' title="商品详情" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
	  <!-- #endif -->	
	  
	    <view class="bg-white" style="border-radius: 8rpx !important;">
	  	   <bw-swiper-special :swiperList="goods_info.goods_images" :swiperType="true" :autoplay="true"  :swiperHeight="283" style="width:100%"></bw-swiper-special>			
	    </view>
	  
	    <view class="goods-info pl-20  pr-20   pl-20 pt-15 pr-20 pb-30">		
			<view class="flex flex-direction">
				<view class="flex mt-20 mb-20 align-center text-center" >
					<view class="goods_title">
						{{goods_info.goods_title}}
					</view> 				
					<view class="share">	
						<button @click="accessorySet" style="margin-right: -20rpx;">
							<image src="../../../static/resource/share.png" style="width: 32rpx; height: 32rpx;">
						  <text class="share-text ml-5">分享</text>		
						</button>
						
					</view>
				</view>		
				<view class="goods-info-desc">
					<view class="">
						<span class="mr-15">积分</span>
						<span style="color:red">{{goods_info.goods_points}}</span>
					</view>					
					<view class="flex align-center text-center">
						<image src="../../../static/resource/fee.png" style="width: 29.97rpx;height: 30rpx;" mode="aspectFill"></image>
						<span class="ml-15" style="font-size: 28rpx;color: #999999;">运费到付</span>
					</view>					
			    </view>			
		    </view>  		   
	    </view>
		
		<view class="goods-content  pl-20  pr-20   pl-20 pt-15 pr-20 ">
			<view class="flex mt-20 mb-20 align-center text-center buy_info">
				<view class="flex" style="width: 30%;" @click="goods_desc(1)">商品详情</view>	
				<view class="flex">|</view>
				<view class="flex" style="width: 40%;" @click="goods_desc(2)">购买须知</view>
		    </view>  
			<view class="flex justify-start align-center border-b pb-15">
				<iconfont class="mt-5" icon="icon-img" color="#333333" size="40rpx" />
				<text class="ml-10" style="color: #4D4D4D;" v-if="type ==1">商品详情</text>
				<text class="ml-10" style="color: #4D4D4D;" v-if="type ==2">购买须知</text>
		    </view>
		   <view class="mt-20">
				
				<rich-text :nodes="change(goods_info.goods_content)" v-if="type ==1"></rich-text>
				<rich-text :nodes="change(goods_info.goods_points_content)" v-if="type ==2"></rich-text>
		    </view>
		</view>
		<!-- 
		<view class="">
			<button class="classify-cell-recom bg-white" open-type="share">				
				<text class="mt-10">微信好友</text>
			</button>
		</view> -->
		
		<view class="" style="padding-bottom: 150rpx;">		
					
		</view>
		<!-- 配件信息 -->
		<biz-accessory :show="showaccessory" @accessoryCancel="accessoryCancel" ref="accessory"></biz-accessory> 
	    <t-submit-bar :show="showSelection" :maskClosable="showSelection" :car_total="car_total" :goodsId="goodsId" :is_collect.sync="goods_info.is_collect"  @confirm="confirm" :type="settle_type" @editCar="editCar"></t-submit-bar>	 	
	</view>	
</template>

<script>
	import submitbar from "@/components/submit-bar/index.vue";
	import accessory from "@/components/accessory/index.vue";
	export default {
		components: {
		   "t-submit-bar": submitbar,
		    "biz-accessory":accessory,
		},
		data() {
		   	return {
				...getApp().globalData.config,
				goodsId:'',
				goods_info: {},
				car_total:0,
				userInfo:"",
				showSelection:true,
				settle_type:7,
				currentTab:1,
				showShop:false,//发货信息
				showaccessory:false,//配件信息
				showuse:false,//配件使用说明,
				is_collect:false,
				eval_list:[],
				type:1,
			}
		},
		onShow() {
			this.goodsInfo()
			 if(uni.getStorageSync('userInfo')){      
			    this.userInfo=uni.getStorageSync('userInfo')
			    
			}
				
		},
		
		
		//分享朋友圈
		onShareTimeline(res) {
			return {
				title:'邀请好友使用YOMeeDoll!',
				imageUrl: this.api_url+'/static/upload/ca44c3de4c3f1856/9248ada602a392f3.jpg',//展示的图片，这里是本地路径的写法，也可以写http或https开头的图片路径
			    path:'/pages/mine/index?recommendId='+this.userInfo.id,//页面 path ，必须是以 / 开头的完整路径
			}
		},
		// 分享到好友
		//分享
		onShareAppMessage(res){
			console.log('分享')
			return{
				provider:'weixin',
				title:'邀请好友使用YOMeeDoll!',
				path:'/pages/mine/index?recommendId='+this.userInfo.id,//页面 path ，必须是以 / 开头的完整路径
				imageUrl:this.api_url+'/static/upload/ca44c3de4c3f1856/9248ada602a392f3.jpg',
				desc:'',
			}
		},
		onLoad(event) {
			console.log('event',event)
			this.goodsId=event.id
			    wx.showShareMenu({
				    menus: ['shareAppMessage', 'shareTimeline'],//'shareAppMessage'打开分享好友功能 | 'shareTimeline'打开分享到朋友圈功能
			    });
			
		},
		methods:{
			//关闭下载
			goods_desc(type){
			   this.type=	type
			},
		
			
			...getApp().globalData.function,
			//关闭下载
			accessoryCancel(){
				this.showaccessory=false
			},
			//打开下载
			accessorySet(){
				this.showaccessory=true
			},
			// onShareAppMessage(e){
			// 	let userInfo=this.userInfo
			// 	let recommId='';
			// 	if(userInfo)  recommId=userInfo.id
			// 	return {
			// 		title:this.project_cn, //标题名字
			// 		path:"/pages/mine/index?recommId="+recommId+"&id="+this.goodsId, //指定页面的路径和需要携带的参数
			// 		imageUrl:this.goods_info.goods_image//分享的封面
			// 	}
			// },			
			editCar(event){
				this.car_total=event.num
			},
		
		 
			 
			
			 change(data){
				if(data){
					let html = data.replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img style="width: 100%;" $1');
					return html
				}
			},
			 
			//获取商品信息
		    goodsInfo(){
				let that=this 
				let obj_data={
				   goodsId:this.goodsId
				}  
				if(uni.getStorageSync('userInfo')){
					obj_data.token=uni.getStorageSync('userInfo').token
				}
				
			    this.$http.pointsInfo(obj_data).then(res =>{
				 if(res.resCode=="9999"){					
				    that.goods_info=res.data.lists
				 }else{
				   uni.showToast({title:res.resMessage,icon:"none"})
				 }
			 })
		    }			   
		}
	}
</script>

<style>
	@import "./detail.css";
</style>